package it.gestionedocumentale.struts.form;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

public class LoginForm extends ActionForm {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private String login;
	private String password;
	
	public void setLogin(String login) {
		this.login = login;
	}
	public String getLogin() {
		return login;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getPassword() {
		return password;
	}
	
	
	public ActionErrors validate(ActionMapping arg0, HttpServletRequest arg1) {
		
		ActionErrors errors = new ActionErrors();
		
		if (this.getLogin().equals("")) {
			errors.add("login", new ActionMessage("errors.LoginForm.login.campo_vuoto"));
		}
		if (this.getPassword().equals("")) {
			errors.add("password", new ActionMessage("errors.LoginForm.password.campo_vuoto"));
		}
		
		return errors;
	}

}
